package edu.zut.cs.software.perfect.teacher.domain;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import edu.zut.cs.software.perfect.base.domain.BaseTreeEntity;

/**
 * @ClassName Department
 * @Description TODO
 * @Author lixianglong
 * @Date 2020年6月2日 下午11:47:37
 * @Version 1.0
 */
@Entity
@Table(name="T_DEPARTMENT")
@NamedQueries({ @NamedQuery(name = "Department.getRoot", query = "select m from Department m where m.parent is null") })
public class Department extends BaseTreeEntity<Department,Long>{
	
	
	
	@OneToMany(mappedBy = "department", cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	List<Teacher> teachers;
	
	private static final long serialVersionUID = 4373909818672794337L;
	
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	/*
	 * Code for department
	 * */
	@Column(name="DEPARTMENTCODE")
	String departmentCode;
	
	public String getDepartmentCode() {
		return departmentCode;
	}
	public void setDepartmentCode(String departmentCode) {
		this.departmentCode = departmentCode;
	}
	public String getDepartmentName() {
		return departmentName;
	}
	public void setDepartmentName(String departmentName) {
		this.departmentName = departmentName;
	}
	/*
	 * name for departmentName
	 * */
	@Column(name="DEPARTMENTNAME")
		String departmentName;
	
	
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
	}
	@Override
	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}
	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}
	
	

}
